package org.example.maven.pojo.utils;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.example.maven.pojo.Collection;
import org.example.maven.utils.MapToJsonConverter;
import org.w3c.dom.Text;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Map;

@Entity
@Table(name = "collection")
@NamedQueries({
})
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CollectionJpa extends IdEntity{
    @Column(name = "internal_id", nullable = false, unique = true)
    private  String internalId;
    @Column(name = "name")
    private String name;
    @Column(name = "alternate_name")
    private String alternateName;
    @Column(name = "classification_id", nullable = false, unique = true)
    private Integer classificationId;
    @Column(name = "era_id", nullable = false, unique = true)
    private Integer eraId;
    @Lob
    @Column(name = "description", columnDefinition = "TEXT")
    private String description; // 字段类型必须为 String
    @Enumerated(EnumType.STRING)
    @Column(
            name = "preservation_status",
            columnDefinition = "ENUM('完好','轻微损伤','严重损伤','修复中') DEFAULT '完好' COMMENT '保存状态'"
    )
    private PreservationStatus preservationStatus = PreservationStatus.完好;
    @Column(name = "weight")
    private BigDecimal weight;
    @Column(name = "current_location", nullable = false, unique = true)
    private String currentLocation;
    @Enumerated(EnumType.STRING)
    @Column(
            name = "status",
            columnDefinition = "ENUM('在库','展出','外借','修复中','已注销') DEFAULT '在库' COMMENT '当前状态'"
    )
    private CollectionStatus status = CollectionStatus.在库;
    @Column(name = "updated_at", nullable = false, unique = true)
    private LocalDateTime updatedAt;
    @Column(name = "img")
    private String img;

    // 保存状态枚举
    public  enum PreservationStatus {
        完好, 轻微损伤, 严重损伤, 修复中
    }

    // 藏品状态枚举
    public enum CollectionStatus {
        在库, 展出, 外借, 修复中, 已注销
    }
}
